//前端自身下载
export const downloadFile = (filePath,fileName) => {
    fetch(filePath).then(res => res.blob()).then(blob => {
        const a = document.createElement('a');
        document.body.appendChild(a)
        a.style.display = 'none'
        // 使用获取到的blob对象创建的url
        const url = window.URL.createObjectURL(blob);
        a.href = url;
        // let fileName=filePath.substring(filePath.lastIndexOf('/')+1)
        a.download = fileName;
        a.click();
        document.body.removeChild(a)
        // 移除blob对象的url
        window.URL.revokeObjectURL(url);
    });
}
//和后端配合下载
export const downloadFile2 = (filePath,fileName)=>{
    let a = document.createElement("a");
    a.setAttribute("href",filePath);
    a.setAttribute("download",fileName);
    a.click();
}
